#include "FrequencyBuilder.h"
#include <assert.h>

class UnitTest
{
public:
	static void TestFrequencyBuilder(IFrequencyTable* inputTable)
	{
		map<char, int> m;
		m['H'] = 1;
		m['e'] = 1;
		m['l'] = 3;
		m['o'] = 2;
		m['W'] = 1;
		m['r'] = 2;
		m['d'] = 1;
		m['I'] = 1;
		m['a'] = 1;
		m['m'] = 1;
		m['s'] = 1;
		m['t'] = 1;
		m['i'] = 6;
		m['n'] = 1;
		m['g'] = 1;
		m[' '] = 4;
		m['!'] = 2;
		m[(char)-1] = 1;
		FrequencyTable tab(m);
		size_t n = tab.count();
		inputTable->reflesh();
		for(size_t i = 0; i < n; ++i)
		{
			char c1 = tab.getCurrentChar();
			int f1 = tab.GetFrequency(c1);
			int f2 = inputTable->GetFrequency(c1);
			assert(f1 == f2);
			tab.moveIterator();
		}
		inputTable->reflesh();
	}
};